package com.wltjack.springboot.controller.jms;

import java.text.SimpleDateFormat;
import java.util.Date;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.amqp.core.AmqpTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

@Component
public class HelloSender {
	private transient final Logger log = LoggerFactory.getLogger(getClass());
	@Autowired
	private AmqpTemplate template;
	private static SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
	
	public void send() {
		String msg = "hello,rabbit!" + sdf.format(new Date());
		log.info("HelloSender > send() send to Queue[name='rabbit.mq.queue'] msg: " + msg);
		template.convertAndSend("rabbit.mq.queue", msg);
	}
	

}
